home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / dom / nsIFocusController.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  4KB  |  129 lines

  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  * vim: set ts=3 sw=2 et tw=80:
  3.  *
  4.  * ***** BEGIN LICENSE BLOCK *****
  5.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6.  *
  7.  * The contents of this file are subject to the Mozilla Public License Version
  8.  * 1.1 (the "License"); you may not use this file except in compliance with
  9.  * the License. You may obtain a copy of the License at
  10.  * http://www.mozilla.org/MPL/
  11.  *
  12.  * Software distributed under the License is distributed on an "AS IS" basis,
  13.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14.  * for the specific language governing rights and limitations under the
  15.  * License.
  16.  *
  17.  * The Original Code is the Mozilla browser.
  18.  *
  19.  * The Initial Developer of the Original Code is
  20.  * Netscape Communications, Inc.
  21.  * Portions created by the Initial Developer are Copyright (C) 1999
  22.  * the Initial Developer. All Rights Reserved.
  23.  *
  24.  * Contributor(s):
  25.  *   David W. Hyatt <hyatt@netscape.com> (Original Author)
  26.  *   Dan Rosen <dr@netscape.com>
  27.  *
  28.  * Alternatively, the contents of this file may be used under the terms of
  29.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  30.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  31.  * in which case the provisions of the GPL or the LGPL are applicable instead
  32.  * of those above. If you wish to allow use of your version of this file only
  33.  * under the terms of either the GPL or the LGPL, and not to allow others to
  34.  * use your version of this file under the terms of the MPL, indicate your
  35.  * decision by deleting the provisions above and replace them with the notice
  36.  * and other provisions required by the GPL or the LGPL. If you do not delete
  37.  * the provisions above, a recipient may use your version of this file under
  38.  * the terms of any one of the MPL, the GPL or the LGPL.
  39.  *
  40.  * ***** END LICENSE BLOCK ***** */
  41.  
  42. #ifndef nsIFocusController_h__
  43. #define nsIFocusController_h__
  44.  
  45. #include "nsISupports.h"
  46. #include "nsCOMPtr.h"
  47.  
  48. class nsIDOMElement;
  49. class nsIDOMNode;
  50. class nsIDOMWindowInternal;
  51. class nsIController;
  52. class nsIControllers;
  53. class nsAString;
  54.  
  55. // {AC71F479-17E1-4ee0-8EFD-0ECF2AA2F827}
  56. #define NS_IFOCUSCONTROLLER_IID \
  57. { 0xac71f479, 0x17e1, 0x4ee0, { 0x8e, 0xfd, 0xe, 0xcf, 0x2a, 0xa2, 0xf8, 0x27 } }
  58.  
  59. class nsIFocusController : public nsISupports {
  60. public:
  61.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFOCUSCONTROLLER_IID)
  62.  
  63.   NS_IMETHOD GetFocusedElement(nsIDOMElement** aResult)=0;
  64.   NS_IMETHOD SetFocusedElement(nsIDOMElement* aElement)=0;
  65.  
  66.   NS_IMETHOD GetFocusedWindow(nsIDOMWindowInternal** aResult)=0;
  67.   NS_IMETHOD SetFocusedWindow(nsIDOMWindowInternal* aResult)=0;
  68.  
  69.   NS_IMETHOD GetSuppressFocus(PRBool* aSuppressFlag)=0;
  70.   NS_IMETHOD SetSuppressFocus(PRBool aSuppressFlag, const char* aReason)=0;
  71.  
  72.   NS_IMETHOD GetSuppressFocusScroll(PRBool* aSuppressFlag)=0;
  73.   NS_IMETHOD SetSuppressFocusScroll(PRBool aSuppressFlag)=0;
  74.   
  75.   NS_IMETHOD GetActive(PRBool* aActive)=0;
  76.   NS_IMETHOD SetActive(PRBool aActive)=0;
  77.  
  78.   NS_IMETHOD GetPopupNode(nsIDOMNode** aNode)=0;
  79.   NS_IMETHOD SetPopupNode(nsIDOMNode* aNode)=0;
  80.  
  81.   NS_IMETHOD GetControllerForCommand(const char * aCommand, nsIController** aResult)=0;
  82.   NS_IMETHOD GetControllers(nsIControllers** aResult)=0;
  83.  
  84.   NS_IMETHOD MoveFocus(PRBool aForward, nsIDOMElement* aElt)=0;
  85.   NS_IMETHOD RewindFocusState()=0;
  86.  
  87.   NS_IMETHOD ResetElementFocus() = 0;
  88. };
  89.  
  90. class nsFocusSuppressor {
  91. public:
  92.   ~nsFocusSuppressor()
  93.   {
  94.     Unsuppress();
  95.   }
  96.  
  97.   // Note: We assume that aReason outlives the instance of this class.
  98.   void Suppress(nsIFocusController *aController, const char *aReason)
  99.   {
  100.     Unsuppress();
  101.  
  102.     mController = aController;
  103.     mReason = aReason;
  104.     if (aController) {
  105.       mController->SetSuppressFocus(PR_TRUE, mReason);
  106.     }
  107.   }
  108.  
  109.   void Unsuppress()
  110.   {
  111.     if (mController) {
  112.       mController->SetSuppressFocus(PR_FALSE, mReason);
  113.       mController = nsnull;
  114.       mReason = nsnull;
  115.     }
  116.   }
  117.  
  118.   PRBool Suppressing()
  119.   {
  120.     return mController != nsnull;
  121.   }
  122.  
  123. private:
  124.   nsCOMPtr<nsIFocusController> mController;
  125.   const char *mReason;
  126. };
  127.  
  128. #endif // nsIFocusController_h__
  129.